home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: speed2.java,v 1.7 1996/10/03 19:46:51 hudson Exp $
- * $Author: hudson $
- */
-
- package sub_arctic.test;
-
- import sub_arctic.constraints.std_function;
- import sub_arctic.constraints.std_constraint_consts;
- import sub_arctic.lib.manager;
- import sub_arctic.lib.interactor;
- import sub_arctic.lib.base_interactor;
- import sub_arctic.lib.base_parent_interactor;
- import sub_arctic.lib.interactor_consts;
- import sub_arctic.lib.top_level;
-
- class bench_interactor extends base_interactor {
- /** W/H only constructor */
- public bench_interactor(int wv, int hv) { super(0,0,wv,hv); }
-
- /** Override set_raw_x so we do not declare screen damage in benchmark */
- public void set_raw_x(int v) { _x = v; }
-
- /** Override set_raw_y so we do not declare screen damage in benchmark */
- public void set_raw_y(int v) { _y = v; }
-
- /** Override set_raw_w so we do not declare screen damage in benchmark */
- public void set_raw_w(int v) { _w = v; }
-
- /** Override set_raw_h so we do not declare screen damage in benchmark */
- public void set_raw_h(int v) { _h = v; }
- }
-
- public class speed2 implements std_constraint_consts {
-
- static interactor parent;
- static interactor first_child = null;
- static interactor last_child = null;
-
- public static void setup()
- {
- interactor child = null;
-
-
- parent = new base_parent_interactor(0,0,200,200);
- for (int i = 0; i < chain_size; i++)
- {
- child = new bench_interactor(10,10);
- if (first_child == null)
- first_child = child;
- else
- child.set_x_constraint(std_function.offset(PREV_SIBLING.X(),20));
- parent.add_child(child);
- }
- last_child = child;
-
- }
-
- public static final int num_trials = 100;
- public static final int chain_size = 500;
-
- public static void test()
- {
- for (int i = 0; i < num_trials; i++)
- {
- first_child.set_x(i);
- last_child.x();
- }
- }
-
- public static long[] before = new long[num_trials];
- public static long[] mid = new long[num_trials];
- public static long[] after = new long[num_trials];
-
- public static void split_test()
- {
- for (int i = 0; i < num_trials; i++)
- {
- before[i] = System.currentTimeMillis();
- first_child.set_x(i);
- mid[i] = System.currentTimeMillis();
- last_child.x();
- after[i] = System.currentTimeMillis();
- }
- }
-
- public static void main(String argv[])
- {
- long start_t, end_t;
- float sum;
-
- System.out.println("setting up...");
- setup();
- System.out.println("faulting pages...");
- first_child.set_x(99);
- last_child.x();
- System.out.println("doing " + num_trials + " trials...");
-
- start_t = System.currentTimeMillis();
- test();
- end_t = System.currentTimeMillis();
- // System.out.println("end time = " + end_t);
- // System.out.println("start time = " + start_t);
- System.out.println("elapsed time = " + (end_t - start_t));
- System.out.println("attrs/sec = "+
- (((float)chain_size*num_trials)*1000.0)/((float)(end_t-start_t)));
-
- System.out.println("doing " + num_trials + " trials of split test...");
- split_test();
-
- sum = (float)0.0;
- for (int i = 0; i<num_trials; i++)
- sum += (float)(mid[i] - before[i]);
- System.out.println("ood/sec = "+ (500.0*1000.0*(float)num_trials)/sum);
-
- sum = (float)0.0;
- for (int i = 0; i<num_trials; i++)
- sum += (float)(after[i] - mid[i]);
- System.out.println("eval/sec = "+
- (1000.0*(float)chain_size*num_trials)/sum);
- }
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-